﻿using Common.Builders.Interfaces;
using Common.Entities;
using DataAccess.DAO;

namespace DataAccess.Converters
{
    public class UserEntityConverter : IUserEntityConverter
    {
        private readonly IUserBuilder _userBuilder;

        public UserEntityConverter(IUserBuilder userBuilder)
        {
            _userBuilder = userBuilder;
        }

        public User ConvertToEntity(UserDAO entityDao)
        {
            return _userBuilder.WithUserName(entityDao.UserName).WithPassword(entityDao.Password).Build();
        }

        public UserDAO ConvertToEntityDAO(User entity)
        {
            var userDao = new UserDAO {UserName = entity.UserName, Password = entity.Password};
            return userDao;
        }
    }
}
